<?php
// +----------------------------------------------------------------------
// | Desc: [ Better-充值审核 ]
// +----------------------------------------------------------------------
// | Author: huangzhen_20210406
// +----------------------------------------------------------------------

namespace app\common\model;
use app\api\controller\EmailSend;
use think\facade\Db;

class UserCashError extends Common
{
    //---------------------------------------------后端---------------------------------------------------------------
    /**
     * @param $post
     * @param $type
     * @return array
     */
    public function tableDataAdmin($post)
    {
        $list_rows  = $post['limit'] ?? config('paginate.list_rows');
        $page       = $post['page'] ?? config('paginate.page');

        $where =[];
        if(isset($post['user_name']) && !empty($post['user_name'])){
            $where[] = ['username', '=', trim($post['user_name'])];
        }
        if(isset($post['type']) && strlen($post['type'])>0){
            $where[] = ['type', '=', $post['type']];
        }
//        if(isset($post['datetime']) && !empty($post['datetime'])){
//            $time_list = explode('_' , $post['datetime']);
//            $start_time = strtotime($time_list[0] . " 00:00:00");
//            $end_time   = strtotime($time_list[1] . " 23:59:59");
//            $where[] = ['ctime', 'between', "{$start_time},{$end_time}"];
//        }

        $list = Db::name('user_cash_error')
            ->order('time_error desc')
            ->where($where)
            ->paginate(['list_rows' => $list_rows, 'page' => $page])
            ->toArray();

        return $result = [
            'code'  => 0,
            'msg'   => lang('get info success'),
            'data'  => $list['data'],
            'count' => $list['total'],
        ];
    }
}